//
//  JSMTouringModel.m
//  TakeYouTourTogether
//
//  Created by king on 15/11/26.
//  Copyright © 2015年 king. All rights reserved.
//

#import "JSMTouringModel.h"
#import "JSMTouringDetailModel.h"

@implementation JSMTouringModel

- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    self = [super init];
    if (self) {
        self.userModel = [aDecoder decodeObjectForKey:@"userModel"];
        self.touringId = [aDecoder decodeObjectForKey:@"touringId"];
        self.created_date = [aDecoder decodeObjectForKey:@"created_date"];
        self.last_modified_date = [aDecoder decodeObjectForKey:@"last_modified_date"];
        self.name = [aDecoder decodeObjectForKey:@"name"];
        self.cover = [aDecoder decodeObjectForKey:@"cover"];
        self.photo_number = [aDecoder decodeObjectForKey:@"photo_number"];
        self.start_date = [aDecoder decodeObjectForKey:@"start_date"];
        self.end_date = [aDecoder decodeObjectForKey:@"end_date"];
        self.destination = [aDecoder decodeObjectForKey:@"destination"];
        self.comment_count = [aDecoder decodeObjectForKey:@"comment_count"];
        self.view_count = [aDecoder decodeObjectForKey:@"view_count"];
        self.fav_count = [aDecoder decodeObjectForKey:@"fav_count"];
        self.source = [aDecoder decodeObjectForKey:@"source"];;
        self.postsArr = [aDecoder decodeObjectForKey:@"postsArr"];
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder{
    [aCoder encodeObject:self.userModel forKey:@"userModel"];
    [aCoder encodeObject:self.touringId forKey:@"touringId"];
    [aCoder encodeObject:self.created_date forKey:@"created_date"];
    [aCoder encodeObject:self.last_modified_date forKey:@"last_modified_date"];
    [aCoder encodeObject:self.name forKey:@"name"];
    [aCoder encodeObject:self.cover forKey:@"cover"];
    [aCoder encodeObject:self.photo_number forKey:@"photo_number"];
    [aCoder encodeObject:self.start_date forKey:@"start_date"];
    [aCoder encodeObject:self.end_date forKey:@"end_date"];
    [aCoder encodeObject:self.destination forKey:@"destination"];
    [aCoder encodeObject:self.comment_count forKey:@"comment_count"];
    [aCoder encodeObject:self.view_count forKey:@"view_count"];
    [aCoder encodeObject:self.fav_count forKey:@"fav_count"];
    [aCoder encodeObject:self.source forKey:@"source"];
    [aCoder encodeObject:self.postsArr forKey:@"postsArr"];
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    if ([key isEqualToString:@"created_by"]) {
        self.userModel = [[JSMTouringUserModel alloc] init];
        [self.userModel setValuesForKeysWithDictionary:value];
    }
    if ([key isEqualToString:@"id"]) {
        self.touringId = value;
    }
    if ([key isEqualToString:@"posts"]) {
        self.postsArr = [NSMutableArray array];
        self.postsArr = [JSMTouringDetailModel baseModelByArr:value];
    }
}

@end



